<?php   

/** 
* Controller
* Контроллер 
* @author IT studio IRBIS-team 
* @copyright © 2009 IRBIS-team 
*/
/////////////////////////////////////////////////////////

/**
* Generation of page of an error at access out of system
* Генерация страницы ошибки при доступе вне системы
*/
    if(!defined('IRB_KEY'))
    {
       header("HTTP/1.1 404 Not Found");      
       exit(file_get_contents('../../404.html'));
    } 
//////////////////////////////////////////////////////////
/**
* We connect a file of the MySQL functions
* Подключаем файл функций MySQL
*/  
	include './libs/mysql.php';

$GET['id'] = !empty($GET['id'])?htmlChars($GET['id']):'';

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rss version=\"2.0\" 
	xmlns:atom=\"http://www.w3.org/2005/Atom\"
	xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
	xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">
	<channel>
		<title>Социальный домен</title>
		<link>http://socdomen.ru</link>
		<atom:link href=\"http://socdomen.ru/index.php?page=rss\" rel=\"self\" type=\"application/rss+xml\" />
		<description>Событийная лента проекта \"Социальный домен\"</description>
		<language>ru</language>";

$result = mysqlQuery("SELECT UNIX_TIMESTAMP(create_date) as create_date FROM soc_requests ORDER BY create_date DESC LIMIT 0,1");
$data = mysql_fetch_assoc($result);
$lnd = $data['create_date'];
$upldt = date("r",$lnd); // конвертация даты в формат RFC 2822
echo "
		<lastBuildDate>$upldt</lastBuildDate>
";

$result = mysqlQuery("SELECT sr.title,sr.id,sr.text,UNIX_TIMESTAMP(sr.create_date) as create_date FROM soc_requests sr ORDER BY id DESC LIMIT 0,10");
while ($data = mysql_fetch_assoc($result)) {
echo "	<item>
";
echo "		<guid><![CDATA[http://socdomen.ru/index.php?page=requests&rem=request&id=".$data['id']."]]></guid>
";
echo "		<title>".$data['title']."</title>
";
echo "		<link><![CDATA[http://socdomen.ru/index.php?page=requests&rem=request&id=".$data['id']."]]></link>
";
echo "		<description>".$data['text']."</description>
";

$nd = $data['create_date'];
$updt = date("r",$nd);
echo "		<pubDate>$updt</pubDate>
";
echo "	</item>
";
}

echo "</channel>
</rss>";
?>